<?php
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\DetailView;
use yii\bootstrap\ActiveForm;
use yii\widgets\Pjax;
use yii\widgets\LinkPager;


?>
<?PHP Pjax::begin(['id'=>'assign-user', 'timeout'=>3000, 'linkSelector'=>'#assign-user a', 'enablePushState'=>false]);?>
<style type="text/css">
	.order-view font {color:#9E9A9A;margin-right:10px;}
	.t_header {letter-spacing:2px}
	#_order {font-weight:bold; color: red;}
	#_people {font-weight:bold; color: red;}
	.modal-dialog { width: 1000px;}

	.list-group p {float:left;}
	.list-group label {height:25px;}
	.cus-name{display: inline-block;margin-right: 20px;}
	.cus-name span{margin-right:5px;}
	.input_1{margin-bottom: 5px !important;}
	/* .style-relation {background: rgba(166, 100, 166,0.1);} */
</style>

<?= yii\web\View::registerCssFile("/css/magic-check.css",['depends' => 'app\assets\AppAsset']) ?>
<div class="order-view">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	
		<!-- 显示汇总信息 -->
		<div class="t_header">
			<b><?= $model->name ?></b>
			<b><?= $model->phone?></b>
			<b><?=$model->roomUse->room->name.' '.$model->roomUse->room->code. ' '.$model->roomUse->num.'人间';?></b>
		</div>
	</div>
	<div class="row" style="padding:5px 15px;">

		
		<div class="col-md-12">
			<p>
    			<?php $form = ActiveForm::begin([
								'method' => 'get',
								'action' => Url::to(['/cruise/customer/change', 'id'=>$model->id]),
        						'options' => ['data-pjax'=>true, 'class'=>'form-inline'],
                            ]); ?>
				<div class="form-group input_1">
					姓名
					<input type="text" name="username" class="form-control" value="<?=$name?>">&nbsp;&nbsp;
				</div>


				<div class="form-group input_1">
					电话
					<input type="text" name="phone" class="form-control" value="<?=$phone?>">&nbsp;&nbsp;
				</div>

				<div class="form-group input_1">
					房间备注
					<input type="text" name="remark" class="form-control" value="<?=$remark?>">&nbsp;&nbsp;
				</div>

				<div class="form-group input_1">
					房间代码序号
					<input type="text" name="ord" class="form-control" value="<?=$ord?>">&nbsp;&nbsp;
				</div>
				
				<button type="submit" class="btn btn-info btn-sm">查询</button>
    		<?php ActiveForm::end(); ?>
			</p>
			<div class="t_header" style="margin:20px 0;">
				选择房间
			</div>	
			<ul class="list-group">
				 <?php foreach($room_use as $room){ ?>
				 <li class="list-group-item">
				 <div>
				 	<input class="magic-checkbox assign-magic"  type="checkbox" id="ass_<?= $room->id?>" name="<?= $room->id?>" data-id="<?= $room->id ?>" >
				 	<label for="ass_<?=$room->id?>" >
						<?=$room->room->name.' '.$room->room->code.' '.$room->num.'人间'?> 房间备注：<?=$room->remark?>  房间代码序号：<?=$room->ord?>
					</label>
				 </div>
				 <div>
				 	 <?php if($room->customer){ ?>
				 	 	<?php foreach($room->customer as $c){ ?>
				 	 			<div class="cus-name">
				 	 			<span><?=$c->name?></span><span><?=$c->phone?></span>
				 	 			</div>
				 	 	<?php }?>
				 	 <?php }?>	
				 </div>	
				 </li>
				 <?php }?>
			</ul>

			<?= LinkPager::widget(['pagination' => $pages]); ?>
		</div>
	</div>

</div>


<?php app\components\JsBlock::begin() ?>
<script type="text/javascript">
	var cust_id = "<?= $model->id ?>";
	$(".assign-magic").click(function(){
		if(!confirm("确定要变更房间吗?")){
		   return false;
		}
		var room_id = $(this).data('id');
		var t = $(this);
		$.get("/cruise/customer/change-save", {room_id:room_id, cust_id:cust_id}, function(data){
			if(data){
				alert('变更房间成功!');
				window.location.reload();
			}else{
				alert('分配失败');
				t.prop("checked", false);
			}
    	});
	});	
</script>
<?php app\components\JsBlock::end() ?>
<?php Pjax::end(); ?>